//ac
#include <bits/stdc++.h>
using namespace std;
map<string, int> mapp;
const int WRONG = 200100;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string name, ss;
    cin >> name >> ss;
    // 如果该同志姓名在mapp中第一次出现过
    if (mapp.count(name) == 0) {
      mapp.insert(make_pair(name, 0));
      //   if (ss == "exit")
      //     mapp[name] = WRONG;
    }

    if (mapp[name] == WRONG)
      continue;
      
    if (ss == "exit")
      mapp[name] -= 1;
    else if (ss == "enter")
      mapp[name] += 1;

    if (mapp[name] >= 2 || mapp[name] < 0) // 这里<0需注意。容易错
      mapp[name] = WRONG;
  }
  // 遍历map并输出元素
  for (const auto &pair : mapp) {
    if (pair.second != 0)
      cout << pair.first << " ";
  }
  return 0;
}